﻿/*************************************************
作者: Plane
邮箱: 1785275942@qq.com
功能: tips弹窗提示

           ~~获取更多教学资讯~~
//----------------*----------------\\
        教学官网：www.qiqiker.com
        官方微信服务号: qiqikertuts
        Plane老师微信: PlaneZhong
\\----------------*----------------//
*************************************************/

using UnityEngine;
using UnityEngine.UI;
using System.Collections.Generic;

public class TipsWnd : WindowRoot {
    //-------------Declaration----------------//
    public Image bgTips;
    public Text txtTips;
    public Animator ani;
    bool isTipsShow = false;
    readonly Queue<string> tipsQue = new();

    //-------------Flow Functions-------------//
    protected override void InitWnd() {
        base.InitWnd();
        SetActive(bgTips, false);
        tipsQue.Clear();
    }
    private void Update() {
        if (tipsQue.Count > 0 && isTipsShow == false) {
            string tips = tipsQue.Dequeue();
            isTipsShow = true;
            int len = tips.Length;
            SetActive(bgTips);
            txtTips.text = tips;
            bgTips.GetComponent<RectTransform>().sizeDelta = new Vector2(35 * len + 100, 80);

            ani.Play("TipsWnd", 0, 0);
        }
    }

    //-------------Tool Functions-------------//
    public void AddTips(string tips) {
        tipsQue.Enqueue(tips);
    }
    public void AniPlayDone() {
        SetActive(bgTips, false);
        isTipsShow = false;
    }
}